﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyVideoPlayer.Converters
{
    public class VolumeToDoubleConverter : ValueConverterBase
    {
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int v)
                return v / 100.0;
            if (value is double d)
                return d / 100.0;
            return 0.5;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double d)
                return (int)Math.Round(d * 100);
            if (value is int v)
                return v;
            return 50; // 默认值
        }
    }
}
